<!DOCTYPE html> 
<html>
  <head>
    <!--META-->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.75">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    <!--CSS-->
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.min.css" />
    <link rel="stylesheet" href="API/css/datatables/css/jquery.dataTables.css"/>
    <link rel="stylesheet" href="API/css/mycss.css" />
    <link rel="stylesheet" href="css/mycss.css" />

    <!--JS-->
    <script type="text/javascript" src="API/js/jquery.min.js"></script>
    <script type="text/javascript" src="API/js/jquery.mobile.min.js"></script>
    <!--<script type="text/javascript" src="API/js/highcharts.js"></script>-->
    <!--<script type="text/javascript" src="API/js/modules/exporting.js"></script>-->
    <script type="text/javascript" src="API/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="include/config.js"></script>
    <script type="text/javascript" src="API/js/fonctions.js"></script>
    <script type="text/javascript" src="js/fonctions.js"></script>

    <script type="text/javascript">
    checkMaintenance();
    checkAuthentification();
    
    ///////////////////
    //BLOCK VARIABLE GLOBAL
    ///////////////////
    var id_page = 6;

    ///////////////////
    //BLOCK FONCTIONS EVENEMENTS
    ///////////////////
    //A la construction de la page
    $(document).on('pageinit',function() {
        try {
            // Init commmun
            init_commun();

            // Init page
        }
        catch (er) {
            log(0, "ERROR(init_home):" + er.message);
        }
    });

    //Affichage de la page avant onload
    $(document).on('pageshow',function() {
        try {
            show_commun();
        }
        catch (er) {
            log(0, "ERROR(show):" + er.message);
        }
    });

    //Fin chargement page
    function OnLoad() {
        try {
            chargerMetricsInterface();
        }
        catch (er) {
            log(0, "ERROR(OnLoad):" + er.message);
        }
    }

    ///////////////////
    //BLOCK FONCTIONS METIER
    ///////////////////
    /**
     * chargerMetricsInterface
     */
    function chargerMetricsInterface(){
        try {
            var strhtml = "<IMG SRC=\"API/img/loading.gif\" ALT=\"Chargement\" TITLE=\"Chargement\">";
            $('#div_metrics_interface').html(strhtml);
            var tabInput = { };
            callBD("API/phpsql/getMetricsInterface.php", "POST", "text", tabInput, "retourMetricsInterface");            
        }
        catch (er) {
            log(0, "ERROR(chargerMetricsInterface):" + er.message);
        }
    }

    ///////////////////
    //BLOCK FONCTIONS AFFICHAGE
    ///////////////////
    /**
     * retourMetricsInterface
     * 
     * @param {array} p_retour
     */
    function retourMetricsInterface(p_retour){
        try {
            var json_retour = JSON.parse(p_retour);
            if(json_retour["strErreur"] == ""){
                var strhtml = '<table width="60em" cellpadding="0" cellspacing="0" border="0" class="display" id="table_metrics_interface"></table></br></br>';
                $('#div_metrics_interface').html(strhtml).trigger('create');

                var objDataTable = objDataTableFromJsonArray(json_retour["data"]["metrics"]["data"]);
                var oTable = $('#table_metrics_interface').dataTable( {
                        "oLanguage": {
                            "sUrl": "API/css/datatables/dataTables_I8N/lang_FR.json"
                        },
                        "sPaginationType": "full_numbers",
                        "aaData": objDataTable.data,
                        "aaSorting": [[2,'desc']],
                        "aoColumns": [
                            { sTitle: "Interface", sClass: "left", sWidth: "5em" },
                            { sTitle: "Nb", sClass: "center", sWidth: "5em" },
                            { sTitle: "Cost", sClass: "center", sWidth: "5em" },
                            { sTitle: "average", sClass: "center", sWidth: "5em" },
                            { sTitle: "maxTime", sClass: "center", sWidth: "5em" },
                            { sTitle: "minTime", sClass: "center", sWidth: "5em" }
                        ],
                       aoColumnDefs: [
                            {//Interface
                                mRender: function ( data, type, row ) {
                                    return row[0];
                                },
                                aTargets: [ 0 ]
                            },
                            {//Nb
                                mRender: function ( data, type, row ) {
                                    return row[1];
                                },
                                aTargets: [ 1 ]
                            },
                            {//Cost
                                mRender: function ( data, type, row ) {
                                    return row[2];
                                },
                                aTargets: [ 2 ]
                            },
                            {//average
                                mRender: function ( data, type, row ) {
                                    return row[3];
                                },
                                aTargets: [ 3 ]
                            },
                            {//maxTime
                                mRender: function ( data, type, row ) {
                                    return row[4];
                                },
                                aTargets: [ 4 ]
                            },
                            {//minTime
                                mRender: function ( data, type, row ) {
                                    return row[5];
                                },
                                aTargets: [ 5 ]
                            }
                        ]
                    });
            } else{
                $('#div_metrics_interface').html(json_retour["strErreur"]);
            }
        } catch (er) {
            log(0, "ERROR(retourMetricsInterface):" + er.message);
        }
    }
</script>

</head>
<body onload="OnLoad();">

    <!-- page -->
    <div data-role="page" data-title="Titre">

        <!-- /panel -->
        <div data-role="panel" id="mypanel" data-display="overlay" data-position="left">

        </div>
        <!-- /panel -->

        <!-- header -->
        <div data-role="header" data-position="fixed">
            <a href="#mypanel" data-role="button" data-icon="home" data-iconpos="notext">home</a>
            <h1 id="id_titre">titre</h1>
            <a href="javascript:window.location = ('./page_contact.html?mili='+getMilise());" data-role="button" data-icon="info" data-iconpos="notext">Contact</a>
        </div>
        <!-- /header -->

        <!-- content -->
        <div data-role="content" id="main_content">
            <div data-role="collapsible" data-collapsed="false" data-mini="true">
                <h4>Les metrics des interfaces</h4>
                <div id="div_metrics_interface">Anomalie code EXXX</div>
            </div>      
        </div>
        <!-- /content -->

        <!-- footer -->
        <div data-role="footer" data-position="fixed">
            <a data-role="button" data-icon="search" data-iconpos="notext" class="ui-btn-left" href="javascript:window.location = ('./page_faq.html?mili='+getMilise());">FAQ</a>
            <h1 id="id_affichageUser">User</h1>
            <a data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right" href="javascript:window.location = ('./page_sortie.html?mili='+getMilise());">Logout</a>
        </div>
        <!-- /footer -->

    </div>
    <!-- /page -->
</body>
</html>